<template>
  <div class="news-detail">
    <myheader outerTitle="新闻详情"></myheader>
    <div>
      <h1 class="news-title">{{newsDetail.title}}</h1>
      <p class="news-info">
        <span>{{newsDetail.add_time | filterTime}}</span>
        <span>{{newsDetail.click}}次浏览</span>
        <span>瓜皮分类</span>
      </p>
    </div>
    <div class="news-content" v-html="newsDetail.content"></div>
    <comment :id="id"></comment>
  </div>
</template>

<script>
import { getNewsDetail } from '@/api'
import myheader from '@/components/myheader.vue'
import comment from '@/components/comment.vue'
export default {
  components: {
    myheader,
    comment
  },
  created () {
    this.initDetail()
  },
  data () {
    return {
      newsDetail: {},
      id: this.$route.params.id
    }
  },
  methods: {
    initDetail () {
      getNewsDetail(this.id)
        .then(res => {
          // console.log(res)
          this.newsDetail = res.message[0]
        })
    }
  }
}
</script>

<style lang="scss">
.news-detail {
  padding: 40px 0 0 0;
  .news-title {
    font-size: 14px;
    font-weight: bold;
  }
  .news-info {
    font-size: 12px;
    color: #26a2ff;
    display: flex;
    justify-content: space-between;
  }
  .news-content {
    font-size: 12px;
  }
}
</style>
